/*
 * Copyright (C) 2011 Mette Bank, Rikke Jensen, Kenneth Brodersen, Thomas Pedersen
 * 
 * This file is part of digiPECS.
 * 
 * digiPECS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * digiPECS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with digiPECS.  If not, see <http://www.gnu.org/licenses/>.
 */

package sw6.digipecs.admin;

import sw6.digipecs.R;
import sw6.digipecs.exceptions.IDNotFoundException;
import sw6.digipecs.interfaces.ImageModificationListener;
import sw6.digipecs.model.ExtImage;
import sw6.digipecs.widget.admin.HelpView;
import sw6.digipecs.widget.admin.ImageModifyView;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

public class EditPictureActivity extends Activity implements ImageModificationListener {
	public static final String EXTRA_PICTUREID = "imageid";
	public static final int REQUEST_CODE = 248;
	private int mId;
	private ExtImage mSelectedPicture;
	private ImageModifyView mImageModifierView;
	private Context mContext;
	private HelpView mHelpView; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.editpicturelayout); 
		mContext = getApplicationContext();
		mImageModifierView = (ImageModifyView)findViewById(R.id.modifyImageCompoundView); 
		
		mId = getIntent().getExtras().getInt(EXTRA_PICTUREID); 
		try {
			mSelectedPicture=new ExtImage(getApplicationContext(), mId);
		} catch (IDNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		mImageModifierView.setSelectedImage(mSelectedPicture); 
		mImageModifierView.setActivity(this); 
		mImageModifierView.setImageModificationListener(this); 
		mHelpView = (HelpView)findViewById(R.id.helpEditPicture); 
		mHelpView.setHeadText("Rediger Egenskaber for Billede"); 
		mHelpView.setBodyText("Her kan indstillinger for et PECS billede ændres\n" +
				"- Brug tekstfeltet til at oprette eller redigere en tekst \n" +
				"- Brug de to play/record knapper til endten at optage en lyd, eller afspille den"); 
	}
	@Override
	public void ImageSaved() {
		Toast.makeText(mContext, "Ændringerne er gemt", Toast.LENGTH_SHORT).show(); 
		this.finish(); 
	}
	@Override
	public void ImageDeleted() {
		Toast.makeText(mContext, "Billedet er slettet", Toast.LENGTH_SHORT).show(); 
		this.finish(); 
	}
}
